Skip to content

Conversation

@wecharyu
Copy link
Contributor

What changes were proposed in this pull request?

Return null for invalid index in get_json_object udf.

Why are the changes needed?

Fix bug.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Add unit test.

json = extract_json_withindex(json, indexList);
if (indexList.isEmpty()) {
// Return null if index is invalid.
return path.contains("[") ? null : json;
Copy link
Member

@deniskuzZ deniskuzZ Nov 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we refactor

  if (indexList.size() > 0) {
    json = extract_json_withindex(json, indexList);
  } else if (path.indexOf('[') >= 0) {
    return null; // index is invalid
  }

Copy link
Member

@deniskuzZ deniskuzZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, pending tests

#### A masked pattern was here ####
CBO PLAN:
HiveProject(id=[$1], id1=[null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], id2=[$0])
HiveProject(a.id=[$1], b.id=[null:VARCHAR(2147483647) CHARACTER SET "UTF-16LE"], c.id=[$0])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is introduced in #6118

@sonarqubecloud
Copy link

@deniskuzZ deniskuzZ merged commit 866cc7d into apache:master Nov 13, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants